package com.lanou.pianke.common.utils;

import com.lanou.pianke.common.entity.PiankeResult;

public class PiankeResultUtils {

    private static final int DEFAULT_SUCCESS_CODE = 200;
    private static final int DEFAULT_FAILURE_CODE = 500;

    public static PiankeResult success(Object data) {
        PiankeResult piankeResult = new PiankeResult();
        piankeResult.setCode(DEFAULT_SUCCESS_CODE);
        piankeResult.setMessage("success");
        piankeResult.setData(data);
        return piankeResult;
    }

    public static PiankeResult error(int code) {
        PiankeResult piankeResult = new PiankeResult();
        piankeResult.setCode(code);
        piankeResult.setMessage("failure");
        return piankeResult;
    }

    public static PiankeResult error() {
        PiankeResult piankeResult = new PiankeResult();
        piankeResult.setCode(DEFAULT_FAILURE_CODE);
        piankeResult.setMessage("failure");
        return piankeResult;
    }
}
